package com.example.springbootdemo.mail;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @Author forsake
 * @Description 登录验证码可以使用邮件，免费
 * 1、开启邮件的pop3/stmp服务，获取三方登入密码
 * 2、配置spring.mail
 * @Date 22:01 2022/12/3
 **/
@SpringBootTest
@RunWith(SpringRunner.class)
public class SendMail {
    @Autowired
    JavaMailSenderImpl mailSender;
    @Test
    public void test1() {
        SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
        simpleMailMessage.setFrom("2271141045@qq.com");
        simpleMailMessage.setSubject("hello world");
        simpleMailMessage.setTo("2271141045@qq.com","qingfang1024@gmail.com","492933096@qq.com");
        simpleMailMessage.setText("hello2");
        for (int i = 0; i < 5; i++) {
            mailSender.send(simpleMailMessage);
        }

    }
}
